package com.luoy; /**
 * @author luoy
 * @date 2018/8/16 0016 下午 1:52
 * @Description: ${todo}
 */

import org.junit.Test;

/**
 * 数组
 *
 * @author LUOYUAN
 * @create 2018-08-16-下午 1:52
 */
public class Array {
    /**
     * 测试数组倒序
     */
    @Test
    public void test1() {
        int[] b = new int[]{1, 2, 3, 4};
        int c = 0;
        int i = 0;
        int j = b.length - 1;
        //倒序
        while (j > i) {
            b[i] = b[i] ^ b[j];
            b[j] = b[j] ^ b[i];
            b[i] = b[i] ^ b[j];
            i++;
            j--;
        }
        for (int k = 0; k < b.length; k++) {
            int i1 = b[k];
            System.out.println(i1);
        }
    }

    /**
     * 测试数组排重
     */
    @Test
    public void test2() {
        int[] a = {1, 2, 3, 4, 3, 2, 1};
        int b = a[0] ^ a[1] ^ a[2] ^ a[3] ^ a[4] ^ a[5] ^ a[6];
        System.out.println(b);
    }
}
